<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>克隆优化节点操作</title>
</head>
<body>
  <p id='oldP'>oldP</p>
  <script>
    for (let i = 0; i < 3; i++) {
      let p = document.createElement('p')
      p.innerHTML = i
      document.body.appendChild(p)
    }

    // 略快
    let oldP = document.getElementById('oldP')
    for (let i = 0; i < 3; i++) {
      // 该方法将复制并返回调用它的节点的副本。如果传递给它的参数是 true，它还将递归复制当前节点的所有子孙节点。否则，它只复制当前节点
      let p = oldP.cloneNode(false)
      p.innerHTML = i
      document.body.appendChild(p)
    }
  </script>
</body>
</html>